<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport"
          content="width=device-width,user-scalable=no, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <title>签约历史</title>
    <%- include('./_global/baseLibs') %>
    <link rel="stylesheet"  href="/static/css/mycontract.css" />
</head>
<style>
    html, body {
        background: #fff;
    }

    .qyls-box2 ul > li > .qyls-a1 {
        bottom: 0.80952rem;
        width: 5.47619rem;
        height: 2.04762rem;
        line-height: 2.04762rem;
        border: 1px solid #087cff;
        color: #087cff;
        font-size: 1.14286rem;
        position: absolute;
        right: 0.95238rem;
        text-align: center;
        border-radius: 6px;
    }

    .qyls-box2 ul > li {
        padding: 0rem 0rem 1.33333rem 0rem !important;
        cursor: pointer;
    }

    .row1 {
        display: inline !important;
    }

    .qyzt1 {
        border: 1px solid #1CA261 !important;
        color: #1CA261 !important;
    }

    .qyzt2 {
        border: 1px solid #C0C0C0 !important;
        color: #C0C0C0 !important;
    }

    .layui-flow-more {
        display: none
    }
    .sign-history .position-box{
        padding-top:0.5rem;
        padding-bottom:0.5rem;
        line-height:1.5;
        height:4.1rem;

    }
    .sign-history .position-box .position-icon{
        position:absolute;
        top:50%;
        left:1rem;
        margin-top:-0.58rem
    }
    .sign-history .position-box span{
        display:block;
        margin-left:3.5rem;
    }
    .sign-history .position-box span.date, .sign-history .position-box .time{
        margin-left:3.5rem;
    }


</style>
<body>
<section class="page-wrap sign-history" id="qyxxContainer">
    <header class="header-box grey fixed">
        <div class="header-content">
            <div class="left-tool">
                <a class="back" href="javascript:void(0);"><i class="iconfont icon-back"></i></a>
            </div>
            <div class="title">签约历史</div>
        </div>
    </header>


</section>
</body>

<script type="text/html" id="qyxx_html">
    <div class="doctor-list-box">
        <a class="position-box" href="javascript:void(0)">
            <i class="position-icon"></i>
            <span name="qyjg"></span>
            <span class="date" name="qysj"></span>
            <i class="arrow-right"></i>
        </a>
        <div class="doctor-list-box">
            <ul>
                <li style="padding: 1rem 1.175rem 1.2rem 1.175rem;position: relative; ">
                    <img src="/static/images/doctors.png">
                    <div class="text-box">
                        <span class="blue-text" name="qytd"></span>
                        <span>
			            <span class="row1">组长：</span>
                        <span name="dzxm" class="row1"></span>
		            </span>
                        <span style="">
                        <span style="float:left">签约服务：</span>
                        <span style="display: inline-block;" name="fwmcs"></span>
		            </span>
                        <span style="">
                        <span >签约周期：</span>
                            <!--<span style="display:block;" name="qyzq" id="qyzq"></span>-->
                         <span style="display:inline;">开始时间：</span>
                         <span style="display:inline;" name="sxsj" ></span>
                             <span style="display:inline;">结束时间：</span>
                            <span style="display:inline;" name="qyjssj"></span>
		            </span>

                    </div>
                    <a class="qyls-a1 df-btn" name="qylxmc"></a>
                </li>
            </ul>
        </div>
    </div>
</script>

<script type="text/html" id="noInfo">
    <ul>
        <li>暂无签约记录</li>
    </ul>
</script>
<script type="text/javascript">
    var uri_service_queryQyHistoryToJkcs = "/api/gzd/qyfw/queryQyHistoryToJkcs";
    var userInfoQyfwYs = StoreCache.getCache("jkcsUserInfo-ys");
    var QYFW_HZXX = StoreCache.getCache("jkcsUserInfo");

    /**分页默认参数*/
    var pageSize = 6;
    /**当前数据*/
    var currData;

    var page_qyls = (function($, page_qyls) {

        function initView() {
            /**跳转我的签约服务*/
            $("#qyxxContainer").on("click", ".df-btn", function () {
                var index = $(this).index(".df-btn");
                var data = currData[index];
                var qyzt = data["qylx"];
                //签约状态 {'00':'预签约','01':'已签约','02':'转介中','03':'已解约','04':'已到期','05':'续约','06':'拒签',,'07':'已接受'}
                if ("00" == qyzt) {
                    $.QuickAlert.alertNormal("请等待团队审核");
                }
                else if ("05" == qyzt) {
                    $.QuickAlert.alertNormal("请等待续约期到");
                }
                else if ("01,02,03,04,07".indexOf(qyzt) > -1 && qyzt != "") {
                    StoreCache.setCache("QYFW_QYLS_QYXX", data);
                    $.QuickUrlUtils.redirectJSBridge({url:"/html/common/signService/wdqyfw.html?qyzt="+qyzt,title:"我的签约服务",type:"qyfw"});
//                $.QuickUrlUtils.redirectJSBridge({url:"/html/signService/wdqyfw.html",title:"我的签约服务"});
                }
                else if ("06" == qyzt) {
                    $.QuickAlert.alertNormal("该签约已被团队拒绝");
                }
            });

            /**团队简介跳转*/
            $("#qyxxContainer").on("click", ".position-box", function () {
                var index = $(this).index(".position-box");
                var data = currData[index];
                StoreCache.setCache("QYFW_TDXX", data);
                $.QuickUrlUtils.redirectJSBridge({url:"/html/common/signService/tdjj.html",title:"团队简介",type:"qyfw"});
//            $.QuickUrlUtils.redirectJSBridge({url:"/html/signService/tdjj.html",title:"团队简介"});
            });

        }

        /**查询当前用户所有的签约信息*/
        function queryQyls() {
            $("#qyls").empty();
            layui.use('flow', function () {
                currData = [];
                var flow = layui.flow;
                flow.load({
                    elem: "#qyxxContainer"
                    , end: " "
                    , done: function (page, next) {
                        // var jmxxid = QYFW_HZXX.userid;
                        $.QuickRemote.AjaxJson({
                            funcName : uri_service_queryQyHistoryToJkcs,
                            params : {
                                // userid : userInfoQyfwYs.userid,
                                zjhm : QYFW_HZXX.sfzh,
                                // jmxxid : jmxxid,
                                // qylxIn : "00",
                                pageSize: "20",
                                pageNumber: "1"
                            },
                            callback : function (result) {
                                var ds = eval(result);
                                var total = ds["total"];
                                var allPage = Math.ceil(total / pageSize);
                                var rows = ds["rows"];
                                currData = currData.concat(rows);
                                var more = allPage > page ? true : false;
                                var items = page_qyls.createQyxxItems(rows);
                                var content = items.join("");
                                next(content, more);
                            }
                        });
                    }
                });
            });
        }
        function createQyxxItems(ary) {
            console.log(ary);
            var qyxxs = [];
            if (ary.length > 0) {
                $.each(ary, function (index, item) {
                    var qyxx = page_qyls.setBaseInfo(item);
                    qyxxs.push($(qyxx).prop("outerHTML"));
                });
            } else {
                var noInfo = $($("#noInfo").html());
                $("#qyls").remove();
                $(".qyls-box2").css("textAlign", "center");
                $(".qyls-box2").append(noInfo);
            }
            return qyxxs;
        }

        function setBaseInfo(item) {
            var container = $($("#qyxx_html").html());
            item.sxsj = item.sxsj.substr(0,10);
            item.qyjssj = item.qyjssj.substr(0,10);
            container.find("span[name]").each(function () {
                var name = $(this).attr("name");
                var text = item[name];
                $(this).text(text);
                if ("qylxmc" == name) {
                    $(this).addClass("qyzt" + qyzt);
                }
            });
            container.find("a[name=qylxmc]").html(item.qylxmc);
            return container;
        }

        var cfg_def = {
            initView: initView,
            queryQyls: queryQyls,
            createQyxxItems: createQyxxItems,
            setBaseInfo: setBaseInfo,
        }

        page_qyls.init = function(cfg){
            $.extend(page_qyls, cfg_def, cfg);
            page_qyls.initView();
            page_qyls.queryQyls();

        }

        return page_qyls;
    })(jQuery, {});
    

</script>

</html>











